using System.IO;
using Sirenix.OdinInspector.Editor;
using Sirenix.Utilities;
using Sirenix.Utilities.Editor;
using UnityEditor;
using UnityEngine;

namespace LFromeWork
{
    public class LEditor : OdinMenuEditorWindow
    {
        [MenuItem("LTools/LEditor")]
        private static void OpenLEditor()
        {
            LEditor window = GetWindow<LEditor>();
            window.position = GUIHelper.GetEditorWindowRect().AlignCenter(700, 500);
        }

        protected override OdinMenuTree BuildMenuTree()
        {
            OdinMenuTree menuTree = new OdinMenuTree();

            //宏设置
            menuTree.AddAssetAtPath("MacroSettings", "Scripts/FrameworkScripts/LAssets/MacroSettings.asset");
            //参数设置
            menuTree.AddAssetAtPath("ParamsSettings", "Scripts/FrameworkScripts/LAssets/ParamsSettings.asset");
            //AB打包设置
            menuTree.AddAssetAtPath("设置AB打包信息", "Scripts/FrameworkScripts/LAssets/AssetBundleSettings.asset");

            return menuTree;
        }

        #region AssetBundleOpenPersistentDataPath 打开persistentDataPath

        [MenuItem("LTools/打开persistentDataPath")]
        public static void OpenPersistentDataPath()
        {
            string output = Application.persistentDataPath;
            if (!Directory.Exists(output))
            {
                Directory.CreateDirectory(output);
            }

            EditorUtils.ExplorerFolder(output);
        }

        #endregion

        #region AssetBundleOpenPersistentDataPath 打开persistentDataPath

        [MenuItem("LTools/打开AssetBundle文件夹")]
        public static void OpenAssetBundlePath()
        {
            string output = Application.dataPath + "/../" + "AssetBundles/";
            if (!Directory.Exists(output))
            {
                Directory.CreateDirectory(output);
            }

            EditorUtils.ExplorerFolder(output);
        }

        #endregion
    }
}
